package com.java.permission.common.enums;

/**
 * @program: face
 * @author: qingxiangen
 * @create: 2019-09-05 10:22
 * @description: 数据状态枚举
 **/
public enum DataStatusEnum {

    DETELE((byte) 0, "删除"),

    NORMAL((byte) 1, "正常"),

    DISABLED((byte) 2, "停用");

    private byte code;

    private String desc;

    DataStatusEnum() {
    }

    DataStatusEnum(byte code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static DataStatusEnum getEnumByCode(Byte code){
        return getEnumByCode(code == null ? -1 : code.byteValue());
    }

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    public static DataStatusEnum getEnumByCode(byte code){
        for (DataStatusEnum e:  DataStatusEnum.values()) {
            if(code == e.getCode()){
                return e;
            }
        }
        return DETELE;
    }

    public byte getCode() {
        return code;
    }

    public void setCode(byte code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

}
